package com.yswy.domain.entity.tf;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yswy.domain.common.BasePojo;
import com.yswy.domain.entity.user.User;
import com.yswy.domain.vo.gld.addOrUpate.TgDeductionChildAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.TgMediaAccountAddOrUpdate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.time.LocalTime;

@Data
@Builder
@AllArgsConstructor
@Api(tags = "扣量配置")
@TableName(value = "tg_deduction_child")
public class TgDeductionChild{
    @TableId(type = IdType.AUTO)
    private Long deductionChildId;
    @ApiModelProperty("扣量配置ID")
    private Long tgDeductionId;
    @ApiModelProperty("扣量比列")
    private Integer proportion;
    @ApiModelProperty("开始扣量时间")
    private String startTime;
    @ApiModelProperty("结束扣量时间")
    private String endTime;

    public TgDeductionChild(TgDeductionChildAddOrUpdate res, Long tgDeductionId){
        this.tgDeductionId =tgDeductionId;
        this.proportion =res.getProportion();
        this.startTime =res.getStartTime();
        this.endTime =res.getEndTime();

    }
    public TgDeductionChild(){

    }

    public boolean overlapsWith(TgDeductionChild other) {
        LocalTime startTime = LocalTime.parse(this.startTime);
        LocalTime endTime = LocalTime.parse(this.endTime);

        LocalTime otherStartTime = LocalTime.parse(other.startTime);
        LocalTime otherEndTime = LocalTime.parse(other.endTime);

        return !endTime.isBefore(otherStartTime) && !startTime.isAfter(otherEndTime);
    }

}
